<template>
	<view>
		<view class="main">
      <Home v-if="tabName === 0"></Home>
      <Mine v-if="tabName === 1"></Mine>
    </view>
    <!--tab-->
    <u-tabbar
        :value="tabName"
        @change="changeTab"
        :fixed="true"
        :placeholder="true"
        :safeAreaInsetBottom="true"
    >
      <u-tabbar-item text="xx" icon="car" value="home"></u-tabbar-item>
      <u-tabbar-item text="xx" icon="account" value="mine"></u-tabbar-item>
    </u-tabbar>
	</view>
</template>

<script>
  import Home from './home/index.vue'
  import Mine from './mine/index.vue'
  import store from "../../store";
	export default {
    components: {
      Home,
      Mine
    },
		data() {
			return {
				tabName: 0,
        tabComponent: {
          home: Home,
          material: 'material',
          mine: Mine
        },
        pageStyle: {
        }
			}
		},
		methods: {
      toLogin(){
        uni.reLaunch({
          url: '/pages/login/index'
        })
      },
      changeTab(name) {
        this.tabName = name
        // uni.setNavigationBarStyle({
        //   "titleText": "页面标题",
        //   "navigationStyle": "custom"
        // })
      }
		},
    created() {
      const token = uni.getStorageSync("token");
      console.log(token, 'token');
      if (!token) {
        uni.reLaunch({
          url: "/pages/login/index"
        });
      }
    }
	}
</script>

<style>
	.main {
    //padding: 10px;
  }
</style>
